﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Reports.IncomeBook
{
    public partial class InputParamForm : Form,IntegrationInterface.IDIProjectForm
    {
        public InputParamForm()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Reports.IncomeBook.DataSet data = new Reports.IncomeBook.DataSet();
            Reports.IncomeBook.DataSet.InfoRow ir = data.Info.NewInfoRow();
            ir.AptekaName = Util.Common.GetAptekaName(this.ConnectionString);
            DateTime dateF = Util.DTConvert.RoundDate(dtpDateF.Value);
            DateTime dateT = Util.DTConvert.RoundDate(dtpDateT.Value);
            ir.DateF = dateF;
            ir.DateT = dateT;
            data.Info.Rows.Add(ir);
            Reports.IncomeBook.DataLoader.GetData(data.Data, this.ConnectionString, ir.AptekaName, dateF, dateT);
            Reports.IncomeBook.PrintForm pf = new Reports.IncomeBook.PrintForm(data);
            IntegrationInterface.IDIReport rep = pf as IntegrationInterface.IDIReport;
            string repPath = (string)this.CommonProperty;
            rep.InitReport(repPath);
            pf.MdiParent = this.MdiParent;
            pf.Show();
            //this.Close();
        }

        #region IDIProjectForm Members
        private string _connString;
        public string ConnectionString
        {
            get
            {
                return _connString;
            }
            set
            {
                _connString = value;
            }
        }
        string _login;
        public string Login
        {
            get
            {
                return _login;
            }
            set
            {
                _login = value;
            }
        }

        public Form MailForm
        {
            get 
            {
                return this; 
            }
        }
        object _obj;
        public object CommonProperty
        {
            get
            {
                return _obj;
            }
            set
            {
                _obj = value;
            }
        }

        #endregion
    }
}